package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.TCompany;
import com.ruoyi.system.service.ITAccountService;
import com.ruoyi.system.service.ITCompanyService;
import com.ruoyi.system.service.ITCurrencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TReasonMapper;
import com.ruoyi.system.domain.TReason;
import com.ruoyi.system.service.ITReasonService;

import javax.annotation.Resource;

/**
 * 会计项目原因Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-03-17
 */
@Service
public class TReasonServiceImpl implements ITReasonService 
{
    @Autowired
    private TReasonMapper tReasonMapper;



    /**
     * 查询会计项目原因
     * 
     * @param rid 会计项目原因主键
     * @return 会计项目原因
     */
    @Override
    public TReason selectTReasonByRid(Long rid)
    {
        return tReasonMapper.selectTReasonByRid(rid);
    }


    /**
     * 查询会计项目原因列表
     * 
     * @param tReason 会计项目原因
     * @return 会计项目原因
     */
    @Override
    public List<TReason> selectTReasonList(TReason tReason)
    {
        List<TReason> tReasons=tReasonMapper.selectTReasonList(tReason);
        for (TReason tr:tReasons){
            TReason r=new TReason();
            r.setParent(tr.getRid());
            List<TReason> getparens=tReasonMapper.selectTReasonList(r);
            for (TReason tr1:getparens){
                TReason r1=new TReason();
                r.setParent(tr1.getRid());
                List<TReason> getparens1=tReasonMapper.selectTReasonList(r);
                tr1.setParamst(getparens1);
            }
            tr.setParamst(getparens);
        }

        return tReasons;
    }

    @Override
    public List<TReason> selectTReason(TReason tReason) {
        List<TReason> tReasons=tReasonMapper.selectTReason(tReason);
        for (TReason tr:tReasons){
            TReason r=new TReason();
            r.setParent(tr.getRid());
            List<TReason> getparens=tReasonMapper.selectTReasonList(r);
            for (TReason tr1:getparens){
                TReason r1=new TReason();
                r.setParent(tr1.getRid());
                List<TReason> getparens1=tReasonMapper.selectTReasonList(r);
                tr1.setParamst(getparens1);
            }
            tr.setParamst(getparens);
        }

        return tReasons;
    }

    /**
     * 新增会计项目原因
     * 
     * @param tReason 会计项目原因
     * @return 结果
     */
    @Override
    public int insertTReason(TReason tReason)
    {
        return tReasonMapper.insertTReason(tReason);
    }

    /**
     * 修改会计项目原因
     * 
     * @param tReason 会计项目原因
     * @return 结果
     */
    @Override
    public int updateTReason(TReason tReason)
    {
        return tReasonMapper.updateTReason(tReason);
    }

    /**
     * 批量删除会计项目原因
     * 
     * @param rids 需要删除的会计项目原因主键
     * @return 结果
     */
    @Override
    public int deleteTReasonByRids(Long[] rids)
    {
        return tReasonMapper.deleteTReasonByRids(rids);
    }

    /**
     * 删除会计项目原因信息
     * 
     * @param rid 会计项目原因主键
     * @return 结果
     */
    @Override
    public int deleteTReasonByRid(Long rid)
    {
        return tReasonMapper.deleteTReasonByRid(rid);
    }
}
